using System;
using System.IO;
using System.Collections;

namespace Foo
{
	public class Clean
	{
		static ArrayList FilesToDelete;
		static Clean()
		{
			  Clean.FilesToDelete = new ArrayList();
		}
		 
		
		private static void CleanDirectory(DirectoryInfo directory)
		{
			  string[] textArray2 = new string[4] { "bin", "obj", "Debug", "Release" } ;
			  string[] textArray1 = textArray2;
			  if (Array.IndexOf(textArray1, directory.Name) >= 0)
			  {
					Clean.FilesToDelete.Add(directory);
			  }
			  DirectoryInfo[] infoArray1 = directory.GetDirectories();
			  for (int num1 = 0; num1 < infoArray1.Length; num1++)
			  {
					DirectoryInfo info1 = infoArray1[num1];
					Clean.CleanDirectory(info1);
			  }
		}
		 private static void DeleteDirectories()
		{
			  foreach (DirectoryInfo info1 in Clean.FilesToDelete)
			  {
					try
					{
						  if (info1.Exists)
						  {
								info1.Delete(true);
						  }
						  Console.WriteLine("Deleted " + info1.FullName);
						  continue;
					}
					catch (Exception exception1)
					{
						  Console.WriteLine("Error deleting " + info1.FullName);
						  Console.WriteLine(exception1.Message);
						  continue;
					}
			  }
			  Console.WriteLine("Cleaned Directory. Press enter key to exit");
		}
		 
		private static void Main(string[] args)
		{
			  if (args.Length != 0)
			  {
					string text1 = args[0];
					if (Directory.Exists(text1))
					{
						  Clean.CleanDirectory(new DirectoryInfo(text1));
					}
					Clean.DeleteDirectories();
			  }
		}
	}
}